﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.ComponentModel;
using System.Data.Linq;
using System.Runtime.Serialization;

namespace SMSAssistant.Model
{
    [Table(Name = "contract")]
    [DataContract]
    public class Contact : NotificationObject
    {
        [IgnoreDataMember]
        [Column(DbType = "INT NOT NULL IDENTITY", IsDbGenerated = true, IsPrimaryKey = true)]
        public int Id { get; set; }

        string _displayName;
        [Column]
        [DataMember]
        public string DisplayName
        {
            get { return _displayName; }
            set
            {
                NotifyPropertyChanging("DisplayName");
                _displayName = value;
                NotifyPropertyChanged("DisplayName");
            }
        }

        string phoneNumber;
        [Column]
        [DataMember]
        public string PhoneNumber
        {
            get { return phoneNumber; }
            set
            {
                NotifyPropertyChanging("PhoneNumber");
                phoneNumber = value;
                NotifyPropertyChanged("PhoneNumber");
            }
        }

        [Column(IsVersion = true)]
        private Binary _version;

        public override string ToString()
        {
            if (string.IsNullOrEmpty(DisplayName))
                return PhoneNumber;
            else
            {
                return string.Format("{0}#{1}", DisplayName, PhoneNumber);
            }
            //return base.ToString();
        }
    }
}
